#ifndef MYTHREAD_H
#define MYTHREAD_H

#include <QThread>
#include <QTcpSocket>
#include <QString>
#include <QTimer>
#include <QTime>
#include "format.h"

#define MAX_MESSAGE_SIZE 1024

class mythread:public QThread
{
    Q_OBJECT
public:
    mythread();
    mythread(QString name,QString passwd);
    QString     m_name;
    QString     m_passwd;
    u_int32_t   m_position;
    int64_t     m_timestamp;
    u_int8_t    m_isStudy;

    void run();
    void connectServer();
    int saveTimestamp(void * buf,u_int32_t packet_len);
    int delClientRecv(u_int16_t cmd,u_int32_t packet_len,char *buf);

public slots:
    void onConected();
    void onError();
    void onReadData();
    int client_login();
    void onTimeout();

private:
    QTcpSocket *client;
    QTimer *timer;

signals:
    void sigStudyStatuschanged(qint64 status);
};



#endif // MYTHREAD_H
